//
//  PHAsset+Util.h
//  MCCSframework
//
//  Created by qq on 2019/8/15.
//  Copyright © 2019 yhy. All rights reserved.
//

#import <Photos/Photos.h>

NS_ASSUME_NONNULL_BEGIN

@interface PHAsset (Util)

// 附加属性 selected 用于表示选中状态
@property (nonatomic, assign) BOOL selected;

// 获取 url
-(void) getURL:(void (^)(NSURL* _Nullable url))completion;

// 通过 assets-library URL 创建 PHAsset 实例
// 注意，url 必须为 assets-library 格式，普通的 url 返回 nil
+(instancetype)createFromURL:(NSURL*)url;
// 获取图片 data
-(void)fetchImageDataWithBlock:(void (^)(NSData* imageData))block;
// 获取视频 AVAsset
-(void)fetchAVAssetWithBlock:(void (^)(AVAsset * _Nonnull))block;
// 获取视频 data
-(void)fetchVideoDataWithBlock:(void (^)(NSData* videoData))block;
// 保存照片到相册，并返回 asset
+(void)saveImage:(UIImage*)image completion:(void (^)(PHAsset* asset))block;
//调用 creationRequestForAssetFromVideoAtFileURL 保存视频到相册
+(void)saveVideoFile:(NSString*)videoPath completion:(void (^)(PHAsset* asset))block;
// 获取照片库所有图片和视频
+(NSArray<PHAsset*>*)getPHAssets;
// 获得某相册下所有图片视频
+ (NSArray<PHAsset*> *)getAssetsInAssetCollection:(PHAssetCollection *)assetCollection;

@end

NS_ASSUME_NONNULL_END
